#include "TreeClipping.h"
#include "Collision.h"

RECT TreeClipping::clipRECT(RECT OB1, RECT OB2){
	RECT temp;
	temp.top    = 0;
	temp.left   = 0;
	temp.right  = 0;
	temp.bottom    = 0;

	if (!Collision::checkAABBCollision(OB1, OB2))
	{
		return temp;
	}

	if (OB1.top > OB2.top) temp.top = OB2.top;
	else temp.top = OB1.top;

	if (OB1.bottom > OB2.bottom) temp.bottom = OB1.bottom;
	else temp.bottom = OB2.bottom;

	if (OB1.left > OB2.left) temp.left = OB1.left;
	else temp.left = OB2.left;

	if (OB1.right > OB2.right) temp.right = OB2.right;
	else temp.right = OB1.right;

	return temp;
}